sogouExplorer.browserAction.onClicked.addListener(function(tab) { //扩展图标被点击
	sogouExplorer.tabs.sendRequest(tab.id, {msg: "axy1"});
});

sogouExplorer.extension.onRequest.addListener(
function(data){
	if(data.msg.substring(0,5)== "title")
	{
		var str = data.msg.substring(5);
		localStorage.setItem("title", str); //本地存储
	}
	else if(data.msg.substring(0,3)== "tag")
	{
		var str = data.msg.substring(3);
		localStorage.setItem("tag", str);
	}
	else	if(data.msg.substring(0,5)== "intro")
	{
		var str = data.msg.substring(5);
		localStorage.setItem("intro", str);
	}
	else	if(data.msg.substring(0,3)== "url")
	{
		var str = data.msg.substring(3);
		localStorage.setItem("url", str);
	}
	else 	if(data.msg.substring(0,8)== "album_id")
	{
		var str = data.msg.substring(8);
		localStorage.setItem("album_id", str);
		localStorage.setItem("tabs", "1");
		
		//sogouExplorer.windows.create({"url": "web/mainpage.html#tabs-1", "width": 540, "height": 600});
		//sogouExplorer.extension.sendRequest( {
		//	msg : "AAAAAAA"
		//});
		sogouExplorer.windows.create({
			url : "web/mainpage.html#tabs-1",
			focused : true,
			type : "popup",
			width : 480,
			height : 480,
			left : (screen.width - 376) / 2,
			top : (screen.height - 276) / 2
		});	
	}
	
	
	else	if(data.msg.substring(0,10)== "Arraytitle")
	{
		var str = data.msg.substring(10);
		localStorage.setItem("Arraytitle", str);
	}
	else 	if(data.msg.substring(0,8)== "Arrayurl")
	{
		var str = data.msg.substring(8);
		localStorage.setItem("Arrayurl", str);
		localStorage.setItem("tabs", "2");
		
		//sogouExplorer.windows.create({"url": "web/mainpage.html#tabs-2", "width": 540, "height": 600});
		sogouExplorer.windows.create({
				url : "web/mainpage.html#tabs-2",
				focused : true,
				type : "popup",
				width : 480,
				height : 480,
				left : (screen.width - 376) / 2,
				top : (screen.height - 276) / 2
			});	
	}
	else 	if(data.msg.substring(0,10)== "set_cat_id")
	{
		var str = data.msg.substring(10);
		localStorage.setItem("set_cat_id", str);
	}
	else 	if(data.msg.substring(0,13)== "set_repeat_id")
	{
		var str = data.msg.substring(13);
		localStorage.setItem("set_repeat_id", str);
	}
	else 	if(data.msg.substring(0,14)== "set_partner_id")
	{
		var str = data.msg.substring(14);
		localStorage.setItem("set_partner_id", str);
	}
	else 	if(data.msg.substring(0,9)== "set_cover")
	{
		var str = data.msg.substring(9);
		localStorage.setItem("set_cover", str);
	}
	else 	if(data.msg.substring(0,12)== "set_album_id")
	{
		var str = data.msg.substring(12);
		localStorage.setItem("set_album_id", str);
	}
	else 	if(data.msg.substring(0,14)== "set_special_id")
	{
		var str = data.msg.substring(14);
		localStorage.setItem("set_special_id", str);
	}
	

	
	}
);


function genericOnClick(info, tab) { //右键菜单被点击
  sogouExplorer.tabs.sendRequest(tab.id, {msg: "axy2"});
}
sogouExplorer.contextMenus.create( {
	"title" : "提交选择区域给爱西柚",
	"contexts" : [ "selection" ],
	"onclick" : genericOnClick
}); // 右键菜单

